#include("/front/teacher/_layout.html")
#@layout()
#define layoutImportcss()
    <link rel="stylesheet" href="/front/css/framework7-icons.css">
    <link rel="stylesheet" href="/front/css/input.css">
    <link rel="stylesheet" href="/front/css/grid.css">
#end
#define layoutHead()
	<title>登录</title>
#end
#define layoutHome()
            <div class="page-content login-page-content">

                <div class="login-my-screen">
                    <span class="head-portrait head-portrait-big"><img src="/front/img/user.png"></span>
                </div>
                <div class="box">
                    <form id="my-form" class="list login-form no-hairlines-md">
                        <ul>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">person</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="username" type="text" placeholder="手机号" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-verifycode"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">lock</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="password" type="password" placeholder="密码" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                            </li>
                            <li class="msg msg-mobile"></li>
                            <li class="item-content item-input">
                                <div class="item-media">
                                    <i class="f7-icons">images_fill</i>
                                </div>
                                <div class="item-inner">
                                    <div class="item-input-wrap">
                                        <input name="verifycode" type="text" placeholder="验证码" required>
                                        <span class="input-clear-button"></span>
                                    </div>
                                </div>
                                <img id="img_verify" style="height: 36px;" onclick="this.src=this.src+'?c='+Math.random();" src="" />
                            </li>
                        </ul>
                        <div class="block row">
                            <div class="col"><a class="button convert-form-to-data" href="#" id="submit">登录</a></div>
                        </div>
						<div class="block row" style="display: none;">
							<div class="col" style="text-align: center;"><a class="external" href="/front/teacher/html/register" id="a_reg">注册</a></div>
								
							</div>
                    </form>
                </div>
            </div>
    
        
#end
#define layoutImportjs()
	<script type="text/javascript" src="/front/js/form.js"></script>
#end
#define layoutScript()
<script type="text/javascript">
	//checkStorageAuthToken('/front/teacher/user/checkAuth', "/front/teacher/html/index");
	
	clearAuthToken();
	$$('#img_verify').attr('src', '/api/verify?c='+Math.random());
	$$('#submit').on('click', function(){
		if (validateForm('#my-form')){
		  var formData = app.form.convertToData('#my-form');
		   // 调用接口提交数据
		  var url = "/front/teacher/auth/login/6";
		  app.request({
			  url: url,
			  method: "POST",
			  dataType: "json", // 返回数据类型，可以是 json
			  data: formData,
			  success: function(res, status){
				  //console.log(res);
				  if(res.code == 201){
					  myStorage.set(getStorageAuthKey(), res.auth_token);
					  // 请求成功，跳转首页 (动态页面)
					  window.location.href = "/front/teacher/html/index";
				  }else{
					  alert(res.msg);
				  }
			  },
			  error: function(xhr, status){
				  alert(status);
			  }
		  });
		}
	});
</script>
#end